
#include "../include/nosie.glsl"
varying vec3 vPosition;
varying float vWave;
uniform float uTime;
uniform float uPercent;
uniform float uVmin;

varying float vParamsCIndex;
attribute float paramsCIndex;
attribute float paramsCDegree;

void main() {
    vec3 transformed = position;

    float loopY = -(abs(paramsCDegree - 0.5) - 0.5) * 2.;

    float noiseMask = (noise2d(vec2(loopY * 5., uTime * 0.5)) + 1.) / 2.;

    // noiseMask*=(noise2d(vec2(loopY*2.,uTime*0.5))+1.)/2.;
    noiseMask = pow(noiseMask, 3.);

    transformed.y += noiseMask * (paramsCIndex / 2.);

    //消散效果
    float waveSize = 0.5;
    float front = uPercent * (1. + waveSize) - waveSize;
    float back = uPercent * (1. + waveSize);
    float waveStep = smoothstep(front, back, paramsCDegree);

    float noiseWave = random21(position.xz);
    noiseWave = clamp((waveStep * 2. - 1.) + noiseWave, 0., 1.);
    vWave = noiseWave;
    transformed.y += noiseWave * 4.;

    vPosition = transformed;
    vec4 mvPosition = modelViewMatrix * vec4(transformed, 1.0);

    float vMinSize = uVmin / 30.;
    float wSize = vMinSize;
    vParamsCIndex = paramsCIndex;
    gl_Position = projectionMatrix * mvPosition;
    gl_PointSize = wSize * (1. / -mvPosition.z);//clamp(wSize * (1. / - mvPosition.z),0.,vMinSize/10.);
}